package java.util.stream.learn.spi;

import org.junit.jupiter.api.Test;
import sun.misc.Service;

import java.util.Iterator;
import java.util.ServiceLoader;

/**
 * 测试类
 *
 * @author fangjiaxiaobai@gmail.com
 * @date 2019-10-09
 * @since 1.0.0
 */
public class JavaSPITest {

    @Test
    public void sayHello() {

        ServiceLoader<Robot> serviceLoader = ServiceLoader.load(Robot.class);
        serviceLoader.forEach(Robot::sayHello);

        Iterator<Robot> providers = Service.providers(Robot.class);
        providers.forEachRemaining(Robot::sayHello);

    }
}